<script type="text/javascript">
	$(document).ready(function() {
		$('#data').dataTable({
			"bJQueryUI" : true,
			"aoColumnDefs" : [{
				"sType" : "formatted-num",
				"aTargets" : [2, 3]
			}]
		});
		$('.fg-toolbar').css('display', 'none');
	}); 
</script>
<style>
#detalle td{
	height: 30px;
	vertical-align: middle;
	font-weight: bold;
	padding-left: 10px;
	color: #365169;
}
.par td{
	background: #E2E4FF;
}
</style>
<table cellpadding="0" cellspacing="0" border="0" id="detalle" style="width:540px">
	<tr class="par">
		<td>N&deg; Comprobante</td>
		<td><input disabled="true" type="text" value="<?php echo $v['Venta']['nrocomprobante']; ?>"></td>
		<td>Fecha</td>
		<td><input type="text" disabled="true" value="<?php echo $v['Venta']['fecha']; ?>"></td>
	</tr>
	<tr>
		<td>Tipo de Comprobante</td>
		<?php switch($v['Venta']['tipocomprobante']){
				case 0:
					echo '<td><input disabled="true" type="text" value="Recibo"></td>';break;
				case 1:
					echo '<td><input disabled="true" type="text" value="Boleta"></td>';break;
				case 2:
					echo '<td><input disabled="true" type="text" value="Factura"></td>';
		} ?>
		<td>Tienda</td>
		<?php foreach ($tiendas as $t) { ?>
			<?php if($t['Tienda']['id']== $v['Venta']['tiendas_id']) {?>
				<td><input disabled="true" type="text" value="<?php echo $t['Tienda']['nombre']; ?>"></td>
		<?php }} ?>
	</tr>
	<tr class="par">
		<td>Vendedor</td>
		<?php foreach ($vendedores as $ven) { ?>
			<?php if($ven['Vendedore']['id']== $v['Venta']['vendedores_id']) {?>
				<td><input disabled="true" type="text" value="<?php echo $ven['Vendedore']['nombre']; ?>"></td>
		<?php }} ?>
		<td></td>
		<td></td>
	</tr>
	<tr>
		<td>Comprador</td>
		<td><input disabled="true" type="text" value="<?php echo $v['Venta']['comprador'] ?>"></td>
		<td>RUC N&deg;</td>
		<td><input disabled="true" type="text" value="<?php echo $v['Venta']['ruc'] ?>"  maxlength="11"></td>
	</tr>
	<tr class="par">
		<td></td>
		<td></td>
		<td>Monto total</td>
		<td><input disabled="true" type="text" name="data[Venta][comprador]" value="<?php echo 'S/.'.$v['Venta']['total'] ?>"></td>
	</tr>
</table>
<?php
	$submit = array(
		'label' => 'Registrar',
		'name' => 'data[accion]',
		'class' => 'but',
		'div' => false
	);
echo $this->Form->create('Producto', array('action' => 'registrar' ,'type' => 'post')); ?>
<table cellpadding="0" cellspacing="0" border="0" class="display" id="data" style="width:540px">
	<thead>
		<tr>
			<th>Cantidad</th>
			<th>Producto</th>
			<th>Precio unitario</th>
			<th>Monto</th>
		</tr>
	</thead>
	<tbody>
		<?php foreach ($detalles as $d) { ?>
		<tr>
			<td style="vertical-align:middle;"><?php echo $d['Detalle']['cantidad'] ?></td>
			<td style="vertical-align:middle;">
				<?php foreach ($productos as $p) {
					if($p['Producto']['id']==$d['Detalle']['productos_id'])
						echo $p['Producto']['descripcion']; 
				}?>
			</td>
			<td style="text-align:right; vertical-align:middle;">
				<?php foreach ($productos as $p) {
					if($p['Producto']['id']==$d['Detalle']['productos_id'])
						echo 'S/. '.$p['Producto']['precio']; 
				}?>
			</td>
			<td style="vertical-align:middle;"><?php echo $d['Detalle']['monto'] ?></td>
		</tr>
		<?php } ?>
	</tbody>
</table>
<div style="width:510px;text-align:right;"><?php echo $this->Form->end($submit); ?></div>